package com.example.zq;


import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Zhang Qi
 * @date : 2019/11/25
 */
@RestController
public class UserHelloController {
  @Autowired
  private HelloService helloService;
  @GetMapping("/userHello")
  public String userHello(@RequestParam("name") String name){
    return helloService.hello(name);
  }

  @GetMapping("/userOpt")
  public void userOpt(){
    User user=new User();
    user.setId(1);
    user.setUsername("Lime");
    user.setAddress("地球");
    User user1 = helloService.addUser(user);
    System.out.println("新建用户:"+JSON.toJSONString(user1));
    helloService.updateUserById("ZQ", 1);
    User user2 = helloService.getUserById(1);
    System.out.println("修改用户:"+JSON.toJSONString(user2));
    helloService.deleteUserById(1);
    User user3 = helloService.getUserById(1);
    System.out.println("删除用户:"+user3);
  }
}
